package com.zy.openchat.core.model.message;

import android.os.Parcel;
import android.os.Parcelable;

public class InlineKeyboardButton implements Parcelable {
    public String text;
    public InlineKeyboardButtonType type;


    public InlineKeyboardButton(String text,String url){

        this.text= text;
        this.type = new InlineKeyboardButtonType("inlineKeyboardButtonTypeUrl",url);

    }

    public String getUrl(){
        if(type!=null){
            return type.url;
        }
        return "";
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.text);
        dest.writeParcelable(this.type, flags);
    }

    public void readFromParcel(Parcel source) {
        this.text = source.readString();
        this.type = source.readParcelable(InlineKeyboardButtonType.class.getClassLoader());
    }

    protected InlineKeyboardButton(Parcel in) {
        this.text = in.readString();
        this.type = in.readParcelable(InlineKeyboardButtonType.class.getClassLoader());
    }

    public static final Parcelable.Creator<InlineKeyboardButton> CREATOR = new Parcelable.Creator<InlineKeyboardButton>() {
        @Override
        public InlineKeyboardButton createFromParcel(Parcel source) {
            return new InlineKeyboardButton(source);
        }

        @Override
        public InlineKeyboardButton[] newArray(int size) {
            return new InlineKeyboardButton[size];
        }
    };
}
